package com.baocai.tools_redis.controller;


import com.baocai.tools_redis.dao.mapper.TJdItemMapper;
import com.baocai.tools_redis.modal.TJdItem;
import com.baocai.tools_redis.modal.TJdItemExample;
import com.baocai.tools_redis.util.LuaDistributeLock;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {

    @Autowired
    TJdItemMapper tJdItemMapper;

    @Autowired
    LuaDistributeLock luaDistributeLock;


    @RequestMapping("/hello")
    public String hello() {
        return "hello world";
    }


    @RequestMapping("/getJdItem")
    @ResponseBody
    public TJdItem getFlow() {
        TJdItemExample example = new TJdItemExample();
        TJdItemExample.Criteria criteria = example.createCriteria();
        criteria.andIdEqualTo((long) 1);
        return tJdItemMapper.selectByExample(example).get(0);
    }

    @RequestMapping("/getLuaDistributeLock")
    @ResponseBody
    public Boolean getLuaDistributeLock(String key, String value) {
        return luaDistributeLock.lock(key, value);
    }


}
